<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    .quotationTable {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }
    .bottom {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }

    .quotationTable tr:nth-child(even) {
        background-color: white;
    }
    .bottom tr:nth-child(even) {
        background-color: white;
    }

    .quotationTable td {
        border: 1px solid #000000;;
        text-align: center;
        font-size: 13px;
        letter-spacing: 0px;
        line-height: 150%;
    }

    .bottom td {
        border: 1px solid #000000;;
        text-align: center;
        font-size: 16px;
        letter-spacing: 0px;
        line-height: 200%;
    }

    .quotationTable td:last-of-type {
        border: 0;

    }
    .bottom td:last-of-type {
        border: 0;

    }

    .quotationTable tbody tr td {
        font-size: 13px;
        text-align :center;
        text-verticle:center;
    }
    .bottom tbody tr td {
        font-size: 16px;
        text-align :center;
        text-verticle:center;
    }

    .quotationTable thead tr td {
        font-size: 13px;
        font-weight: bold;
        text-align :center;
        text-verticle:center;
    }
    .bottom thead tr td {
        font-size: 16px;
        font-weight: bold;
        text-align :center;
        text-verticle:center;
        line-height: 200%;
    }

    .quotationTable select {
        border: 0;
        width: 100%;
        height: 100%;
        font-size: 13px;
    }

    .bottom select {
        border: 0;
        width: 100%;
        height: 100%;
        font-size: 14px;
    }

    .quotationTable input {
        border: 0;
        width: 100%;
        height: 100%;
    }
    .bottom input {
        border: 0;
        width: 100%;
        height: 100%;
        font-size: 14px;
    }
    .info-table {
        width: 100%;
        border: 0;
        border-collapse: collapse;
    }

    .info-table tr:nth-child(even) {
        background-color: white;
    }

    .info-table td {
        border: 0px;
        text-align: center;
        font-size: 14px;
        letter-spacing: 1px;
        line-height: 180%;
    }

    .info-table tbody tr td {
        font-size: 14px;
    }

    .info-table thead tr td {
        font-size: 14px;
        font-weight: bold;
    }

    .info-table select {
        font-size: 14px;
        padding: 0;
        width: 100%;
        height: 100%;
    }

    .info-table input {
        font-size: 14px;
        padding: 0;
        width: 100%;
        height: 100%;
    }

    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    .quotationTable input[type="number"] {
        -moz-appearance: textfield;
    }

    .bottom input[type="number"] {
        -moz-appearance: textfield;
    }

    .left-part-1 {
        width: 9%;
        text-align: left;
    }

    .left-part-2 {
        width: 23%;

    }

    .right-part-1 {
        width: 9%;
        text-align: left;
    }

    .right-part-2 {
        width: 23%;

    }

    .middle-part {
        width: 30%;
    }

    .help p {
        text-indent: 30px;
    }
    .head-table tr:nth-child(even) {
        background-color: white;
    }
    .bottom tr:nth-child(even) {
        background-color: white;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini">
<div class="modal fade" id="modal-uploadFile">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">上传文件</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <form id="fileForm-send" class="form-horizontal">
                        <input type="hidden" name="quoteId">
                        <input type="hidden" name="fileId">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">文件类型</label>
                                <div class="col-sm-8">
                                    <select type="text" name="fileType" class="form-control">
                                        <option value="" selected="selected">请选择</option>
                                        <option value=1>纸版报价单</option>
                                        <option value=2>其他相关文件</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">文件备注</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="fileComment" placeholder="请输入对文件的说明">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group" style="display: none" id="file">
                                <label class="col-sm-2 control-label">上传文件</label>
                                <input type="file" multiple="multiple" name="file">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-save-file">保存</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="modal-qttTaskList">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">待报价列表</h4>
            </div>
            <div class="modal-body">
                <form id="queryForm-task">
                    <div class="row">
                        <div class="form-inline">
                            <div class="form-group" style="margin-right: 10px;">
                                <label>项目编号</label>
                                <input type="text" name="proCode" class="form-control" placeholder="请输入项目编号">
                            </div>
                            <div class="form-group" style="margin-right: 10px;">
                                <label>项目名称</label>
                                <input type="text" name="proName" class="form-control" placeholder="请输入项目名称">
                            </div>
                            <button type="button" class="btn btn-success" id="btn-search">
                                <span class="Bold">&emsp;搜索&emsp;</span>
                            </button>
                        </div>
                    </div>
                    <button type="button" style = "margin-bottom: 5px" class="btn btn-info pull-left" id="btn-submit-qttTask">添加
                    </button>
                    <table id="bootstrap-table2" style="word-break:break-all; word-wrap:break-all;"></table>
                </form>
            </div>
        </div>
    </div>
</div>
<section class="content-header">
    <h1>编辑报价单</h1>
</section>
<section class="content">
    <form id="queryForm" class="form-horizontal">
        <input type="hidden" id="quoteId" name="quoteId" th:value="${quotationMain.quoteId}">
        <input type="hidden" id="quotationQty" name="quotationQty" th:value="${quotationMain.quotationQty}">
        <input type="hidden" id="qttItemQty" name="qttItemQty" th:value="${quotationMain.qttItemQty}">
        <!--<input type="hidden" id="tasksIdRemove" name="tasksIdRemove">-->
        <!--<input type="hidden" id="tasksIdList" name="tasksIdList" th:value="${quotationMain.tasksIdList}">-->
        <div class="col-lg-pull-12">
            <table class="head-table" style="width: 100%;">
                <tbody style="width: 100%">
                <tr style="border-width:0 0 2px 0;border-style: solid; border-color: #000;">
                    <td style="width: 94%;text-align: center" colspan="3">
                        <div style="display: inline-block;margin-top: 5px;margin-left: 5px">
                            <span style="letter-spacing: 12px;display: block;line-height: 20px">辽宁忠旺机械设备制造有限公司</span>
                            <span style="display: block;font-size: 12px; letter-spacing: 8px; line-height: 20px">www.zhongwangjx.com</span>

                        </div>
                    </td>
                    <td style="width: 6%;display: none"></td>
                </tr>
                <tr>
                    <td style="font-size: 30px; font-weight:bold; height:50px; letter-spacing: 4px;width: 94%;text-align: center"
                        colspan="3">
                        报&nbsp;&nbsp;价&nbsp;&nbsp;单
                    </td>
                    <td style="width: 6%"></td>
                </tr>
                </tbody>
            </table>
            <table class="info-table" style="margin:10px 0px 20px 0px">
                <tbody>
                <tr class="info-row">
                    <td colspan="3" style="text-align: left;font-weight: bold;font-size: 14px">
                        买方信息：
                    </td>
                    <td colspan="2" style="text-align: left;font-weight: bold;font-size: 14px">
                        卖方信息：
                    </td>
                    <td width="6%"> </td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-1" style="text-align: left;">需方名称：</td>
                    <td class="left-part-2">
                        <select id="consumerName" type="text" name="consumerName" class="form-control" style="height: 22px"
                                >
                            <!--onchange="chooseConsumer(this.value)"-->
                            <option selected="selected"
                                    th:value=0
                                    th:text="${quotationMain.consumerName}"></option>
                            <option th:each="consumers:${consumers}"
                                    th:value="${consumers.consInfoId}"
                                    th:text="${consumers.consumerName}"></option>
                        </select>
                    </td>
                    <td class="middle-part"></td>
                    <td class="right-part-1" style="text-align: left;">供方名称：</td>
                    <td class="right-part-2">
                        <input type="text" class="form-control" name="supplierName" style="height: 22px"
                               th:value="${quotationMain.supplierName}">
                    </td>
                    <td style="width: 6%"></td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-1" style="text-align: left;">需方联系人：</td>
                    <td class="left-part-2">
                        <input type="text" class="form-control" name="consumerAttn" style="height: 22px"
                               th:value="${quotationMain.consumerAttn}" >
                    </td>
                    <td class="middle-part"></td>
                    <td class="right-part-1" style="text-align: left;">供方联系人：</td>
                    <td class="right-part-2">
                        <select id="supplierAttn" type="text" name="supplierAttn" class="form-control"  style="height: 22px"
                                onchange="chooseSeller(this.value)">
                            <option selected="selected"
                                    th:value=0
                                    th:text="${quotationMain.supplierAttn}"></option>
                            <option th:each="sellers:${sellers}"
                                    th:value="${sellers.id}"
                                    th:text="${sellers.sellerName}">
                            </option>
                        </select>
                    </td>
                    <td style="width: 6%"></td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-1" style="text-align: left;">需方电话：</td>
                    <td class="left-part-2">
                        <input type="text" class="form-control" name="consumerTel" style="height: 22px"
                               th:value="${quotationMain.consumerTel}" >
                    </td>
                    <td class="middle-part">
                    </td>
                    <td class="right-part-1" style="text-align: left;">供方电话：</td>
                    <td class="right-part-2">
                        <input type="text" class="form-control" name="supplierTel" style="height: 22px"
                               th:value="${quotationMain.supplierTel}">
                    </td>
                    <td style="width: 6%"></td>
                </tr>
                <tr class="info-row">
                    <td class="left-part-1" style="text-align: left;">需方邮箱：</td>
                    <td class="left-part-2">
                        <input type="text" class="form-control" name="consumerEmail" style="height: 22px"
                               th:value="${quotationMain.consumerEmail}">
                    </td>
                    <td class="middle-part">
                    </td>
                    <td class="right-part-1" style="text-align: left;">供方邮箱：</td>
                    <td class="right-part-2">
                        <input type="text" class="form-control" name="supplierEmail" style="height: 22px"
                               th:value="${quotationMain.supplierEmail}">
                    </td>
                    <td style="width: 6%"></td>
                </tr>
                </tbody>
            </table>
            <table class="quotationTable" style="width: 100%">
                <thead>
                <tr>
                    <td style="font-size:14px;font-weight: normal;">
                        1.价格
                    </td>
                </tr>
                <tr>
                    <td style="width: 4%;BORDER-left: 1.5px solid;">序号</td>
                    <td style="width: 13%;">物料名称</td>
                    <td style="width: 11%;">项目名称</td>
                    <td style="width: 10%;">规格型号</td>
                    <td style="width: 5%;">数量</td>
                    <td style="width: 5%;">单位</td>
                    <td style="width: 6%;">不含税</br>单价</td>
                    <td style="width: 6%;">不含税</br>总价(元)</td>
                    <td style="width: 5%;">税率%</td>
                    <td style="width: 5%;">税额</br>(元)</td>
                    <td style="width: 5%;">含税</br>单价</td>
                    <td style="width: 7%;">含税</br>总金额(元)</td>
                    <td style="width: 12.5%;">备注</td>
                    <td style="width: 5.5%;"></td>
                </tr>
                </thead>
                <tbody id="out">
                <tr th:each="quotationSublistModel: ${quotation}">
                    <td th:text="${quotationSublistModelStat.count}">
                    </td>
                    <td>
                        <input style="text-align: center" type="text" class="form-control" name="proName" th:id="'proName_' + ${quotationSublistModelStat.count}"
                               th:value="${quotationSublistModel.proName}" autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="hidden" class="form-control" name="proNames"
                               th:value="${quotationSublistModel.proNames}" autocomplete="off">
                        <div name="names" th:text="${quotationSublistModel.proNames}"  th:id="'names_' + ${quotationSublistModelStat.count}" ></div>
                        <!--<select onchange="selectInfo(this)" class="proCode" name="proCode"-->
                                <!--th:data-index="${quotationSublistModelStat.count}"-->
                                <!--style="border: 0; background: transparent;aria-hidden: false;text-align: center">-->
                            <!--<option selected="selected" th:value="${quotationSublistModel.proCode}"-->
                                    <!--th:text="${quotationSublistModel.proCode}"></option>-->
                        <!--</select>-->
                    </td>
                    <td>
                        <input style="text-align: center" type="text" class="form-control" name="proType"
                               th:value="${quotationSublistModel.proType}" autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="proQty" th:id="'proQty_' + ${quotationSublistModelStat.count}"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.proQty)}" autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="text" class="form-control" name="proUnit" th:id="'proUnit_' + ${quotationSublistModelStat.count}"
                               th:value="${quotationSublistModel.proUnit}" autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="unitPrice"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.unitPrice)}"
                               autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="totalPrice"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.totalPrice)}"
                               autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="taxRate" onKeyUp="keyup()"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.taxRate)}"
                               autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="taxAmount"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.taxAmount)}"
                               autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="unitPriceTaxIncluded"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.unitPriceTaxIncluded)}"
                               autocomplete="off">
                    </td>
                    <td>
                        <input style="text-align: center" type="number" class="form-control" name="totalPriceIncludeTax"
                               onKeyUp="keyup()"   th:id = "'totalPriceIncludeTax_' + ${quotationSublistModelStat.count}"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationSublistModel.totalPriceTaxIncluded)}"
                               autocomplete="off">

                    </td>
                    <td>
                        <input style="text-align: center" type="text" class="form-control" name="remark"
                               th:value="${quotationSublistModel.remark}" autocomplete="off">
                        <input  name="taskIds" type="hidden" th:id = "'taskIds_' + ${quotationSublistModelStat.count}" th:value="${quotationSublistModel.taskIds}">
                        <input  name="customers" type="hidden" th:id = "'customers_' + ${quotationSublistModelStat.count}" th:value="${quotationMain.consumerName}+'/'">
                    </td>
                    <td style="text-align: left;padding-left: 0.5%;">
                        <span class="out-search" title="查找"><i class = "fa fa-search text-light-blue"></i></span>
                        <span class="out-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                        <span class="out-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="3" style="text-align:center;font-weight: bold" >
                        合同总金额（元）
                    </td>
                    <td colspan="3" style="text-align:center;font-weight: bold" >
                        <input type="number"  style="text-align:center;" class="form-control" name="totalAmountIncludedTax" autocomplete="off"
                               th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(quotationMain.totalAmountIncludedTax)}">
                    </td>
                    <td colspan="2" style="text-align:center;font-weight: bold" >
                        合同总金额大写
                    </td>
                    <td colspan="5" style="text-align:center;font-weight: bold;">
                         <input style="margin:  0;text-align: center;background: none" readonly="readonly" name="totalAmtIncTaxInWords" th:value="${'人民币'+ quotationMain.totalAmtIncTaxInWords+'（含'+ quotation.get(0).taxRate +'%增值税）'}" class="form-control">
                    </td>
                    <td style="width: 5.5%"></td>
                </tr>
                <tr style="border:0px;line-height: 22px">
                    <td colspan="13" style="text-align: left;border:0px; font-size: 14px;line-height: 30px">
                        以上价格包含：
                        <input type="checkbox" name="design" style="margi-n-top: 0px;vertical-align: middle" value="1"   th:attr ="checked= ${quotationMain.design == 1 ? true:false}">&thinsp;设计&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="material" style="margin-top: 0px;vertical-align: middle" value="1" th:attr ="checked= ${quotationMain.material == 1 ?true:false}">&thinsp;材料&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="manufature" style="margin-top: 0px;vertical-align: middle"  value="1"    th:attr ="checked= ${quotationMain.manufature == 1 ?true:false}">&thinsp;制造&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="packg" style="margin-top: 0px;vertical-align: middle"  value="1"   th:attr ="checked= ${quotationMain.packg == 1 ?true:false}">&thinsp;包装&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="transport" style="margin-top: 0px;vertical-align: middle"  value="1" onchange="checkTransBox(this.checked)" th:attr ="checked= ${quotationMain.transport == 1 ?true:false}">运输</input>
                        <input name="transMethod" type="text" style="border:1px solid #8c8c8c;width: 20%" onclick="transMethod()" th:value="${quotationMain.transMethod}"> </input>
                        <input type="checkbox" name="install" style="margin-top: 0px;vertical-align: middle"  value="1"  th:attr ="checked= ${quotationMain.install == 1 ?true:false}">&thinsp;安装&nbsp;&nbsp;&nbsp;</input>
                        <input type="checkbox" name="debug" style="margin-top: 0px;vertical-align: middle"  value="1" th:attr ="checked= ${quotationMain.debug == 1 ?true:false}">&thinsp;调试</input>
                    </td>
                </tr>
                <tr style="border:0px;line-height: 28px">
                    <td colspan="13" style="text-align: left;border:0px; font-size: 14px;">
                        <input name="excludeItem" style="width: 97%;border: 1px solid #8c8c8c;margin-left: 3%" th:value="${quotationMain.excludeItem}">
                    </td>
                    <td style="width: 5.5%"></td>
                </tr>
                </tfoot>
            </table>
            <table class="bottom" style="width: 100%; margin: 10px 0px 1px 0px">
                <thead>
                <tr>
                    <td colspan="6" style="width: 100%;font-size: 14px;font-weight: normal; text-align: left">
                        2.付款
                    </td>
                </tr>
                <tr>
                    <td style="width: 5%;BORDER-left: 1.5px solid;">序号</td>
                    <td style="width: 12%;">节点</td>
                    <td colspan="2" style="width: 30%;">条件</td>
                    <td style="width: 10%;">比例%</td>
                    <td colspan="2" style="width:15%;">金额</td>
                    <td colspan="2" style="width:22%;">方式</td>
                    <td style="width: 5.5%;"></td>
                </tr>
                </thead>
                <tbody id="bottom-body">
                <tr th:each="QuotationPayment : ${payItemList}" >
                    <td th:text="${QuotationPaymentStat.count}"></td>
                    <td>
                        <select  style="text-align:center;text-align-last: center;" type="text"  th:id="'payItem_' + ${QuotationPaymentStat.count}" class="form-control" name="payItem" autocomplete="off">
                            <option th:value = "${QuotationPayment.payItem}" th:text="${QuotationPayment.payItemName}" selected="selected"></option>
                            <option th:each="payItems:${payItems}"
                                    th:value="${payItems.id}"
                                    th:text="${payItems.name}">
                            </option>
                        </select>
                    </td>
                    <td colspan="2">
                        <input  style="text-align: center" type="text" class="form-control" name="payCondition" th:value="${QuotationPayment.payCondition}" autocomplete="off">
                    </td>
                    <td>
                        <input  style="text-align: center" type="number" class="form-control" name="payPercent" th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(QuotationPayment.payPercent)}"
                                th:id="'payPercent_' + ${QuotationPaymentStat.count}" onkeyup="computePayAmount(this)" autocomplete="off">
                    </td>
                    <td colspan="2" style="text-align: center;text-vertical:middle">
                        <input  style="text-align: center;text-vertical:middle" type="number" class="form-control" th:id="${'payAmount_' + QuotationPaymentStat.count}" name="payAmount"
                                th:value="${T(com.zhongwang.business.util.BigDecimalUtils).valueFormat(QuotationPayment.payAmount)}" autocomplete="off">
                    </td>
                    <td colspan="2">
                        <select  style="text-align:center;text-align-last: center"  type="value" class="form-control" name="payMethod" autocomplete="off">
                            <option th:value="${QuotationPayment.payMethod}" selected="selected" style="text-align: center">[[${QuotationPayment.payMethodName}]]</option>
                            <option value=1 style="text-align: center">现金</option>
                            <option value=2 style="text-align: center">承兑</option>
                            <option value=3 style="text-align: center">电汇</option>
                            <option value=4 style="text-align: center">支票</option>
                            <option value=5 style="text-align: center">电汇或承兑</option>
                        </select>
                    </td>
                    <td style="text-align: left;padding-left: 0.5%; border: 0px">
                        <span class="item-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                        <span class="item-del" title="删除" ><i class="fa fa-remove text-red"></i> </span>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr >
                    <td colspan="9"  style="font-size: 14px;border: 0px" >
                        <textarea name="quoteBottomDesc" class="form-control" th:text="${quotationMain.quoteBottomDesc}"
                                  style="text-align: left; max-width: 100%; min-width: 100%;   max-height: 140px; min-height: 140px;  font-size: 14px; line-height: 24px; border: 1px solid #dddddd; padding: 10px;resize: none;">
                        </textarea>
                    <td style="width: 5.5%;"></td>
                </tr>
                <tr>
                    <td   colspan="9" style="font-size: 14px;border: 0px;text-align: left">
                        7.审核
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="font-size: 14px;border: 0px;text-align: left">
                        制&nbsp;&nbsp;&nbsp;&thinsp;表&nbsp;&nbsp;&nbsp;&thinsp;人：
                    </td>
                    <td style="width: 15%;font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        销售科：
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        机械设计院：
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="width: 5.5%;"></td>
                </tr>
                <tr>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        生产运营部：
                    </td>
                    <td style="width: 15%;font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        董事长：
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td colspan="2"style="font-size: 14px;border: 0px;text-align: left">
                        集团财务&nbsp;&nbsp;&nbsp;&thinsp;：
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="width: 5.5%;"></td>
                </tr>
                <tr>
                    <td colspan="8" style="font-size: 14px;border: 0px;text-align: left">
                    </td>
                    <td style="font-size: 14px;border: 0px;text-align: left">
                        报价日期：
                    </td>
                    <td style="width: 5.5%;"></td>
                </tr>
                </tfoot>
            </table>
            <div class="row" style="margin: 25px 0 0 0">
                <div class="box" style="width: 94%;padding:0px 0px 0px 0px">
                    <div class="col-md-12" style="padding: 0;height: 44px;line-height: 44px; margin-top: 10px">
                        <span style=" height: 34px; line-height: 34px; font-weight: bold;font-size: 14px">
                            附件信息
                        </span>
                        <button id="uploadFiles" type="button" class="btn btn-success pull-right"
                                onclick="openUploadFile()">上传文件
                        </button>
                    </div>
                    <table id="bootstrap-table1" style="padding-top: 0;"></table>
                </div>
                <div class="box"style="width: 94%;padding:0px 0px 0px 0px;margin-top: 15px" th:if="${not #lists.isEmpty(appList)}">
                    <div class="col-md-12" style="padding: 0; margin: 20px 0 0 0 ">
                        <p style="margin:0px 0px 1px 0px; font-size: 14px; font-weight: bold">审核信息：</p>
                    </div>
                    <table class="table">
                        <tbody>
                        <tr>
                            <th class="text-center">审批人</th>
                            <th  class="text-center">审批时间</th>
                            <th class="text-center">审批结果</th>
                            <th  class="text-center">审批意见</th>
                        </tr>
                        <tr th:each="appList:${appList}">
                            <td th:text="${appList.name}"></td>
                            <td th:text="${#dates.format(appList.appTime, 'yyyy-MM-dd')}"></td>
                            <td th:text="${appList.projectName}"></td>
                            <td th:text="${appList.appRemark}"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--<div class="row" style="" >-->
                <!---->
            <!--</div>-->
            <button type="button" shiro:hasPermission="quo:await:edit"
                    class="btn btn-info pull-right" style="margin:0% 6%" id="btn-save-mainQuote">保存
            </button>
        </div>
    </form>
</section>

<div th:include="include :: footer"></div>
<script th:src="@{/plugin/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js}"></script>
<script th:inline="javascript">
    //行索引
    var index;
    var indexArray = new Array();
    var index1;
    var index2;
    /**
     * 打开上传文件模态框
     */
    function openUploadFile(fileId) {
        var quoteId = $("#quoteId").val();
        $("#fileForm-send input[name ='quoteId']").val(quoteId);

        if (fileId == null || fileId == '') {
            js.modal.open("modal-uploadFile");
            $("#file").show();
        } else {
            $("#file").hide();
            js.post({
                url: ctx + "quoteManage/file/findFileById",
                data: {
                    fileId: fileId
                },
                success: function (result) {
                    $("#fileForm-send").fillData(result);
                    $("#fileForm-send input[name = 'fileType']").val(result.fileType);
                    js.modal.open("modal-uploadFile");
                    js.modal.closeLoading();
                }
            })
        }
    }

    /**
     * 删除文件
     * @param fileId
     */
    function delFile(fileId) {
        js.modal.confirm("确认删除此文件吗？", function () {
            js.post({
                url: ctx + "quoteManage/file/del",
                data: {
                    fileId: fileId
                },
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table1);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            })
        })
    }

    /**
     * 选择供方联系人
     * @param id 供方信息表id
     */
    function chooseSeller(id) {
        if (id == 0) {
            $("#queryForm input[name ='supplierTel']").val('');
            $("#queryForm input[name ='supplierEmail']").val('');
            js.warning("未选择供方信息！");
        } else {
            js.post({
                url: ctx + "quoteManage/createQuotation/querySupplInfo",
                data: {
                    id: id
                },
                success: function (result) {
                    if (result.length != 0) {
                        $("#queryForm input[name ='supplierTel']").val(result.sellerPhone);
                        $("#queryForm input[name ='supplierEmail']").val(result.sellerEmail);
                    } else {
                        js.modal.alert("该供方联系人信息未添加！");
                    }
                }
            })
        }
    }


    /** 计算表格序号 */
    function computerNo() {
        $(".quotationTable tbody tr").each(function (i, e) {
            $(this).children("td:first").text(i + 1);
        });
    }

    /** 计算表格序号 */
    function computerNo1() {
        $(".bottom tbody tr").each(function (i, e) {
            $(this).children("td:first").text(i + 1);
        });
    }

    // /** 项目编号下拉框 */
    // function select3(index) {
    //     js.select3({
    //         id: 'proCode',
    //         placeholder: '',
    //         ajax: {
    //             url: function () {
    //                 return ctx + 'quoteManage/add/project/list'
    //             },
    //             processResults: function (data, page) {
    //                 let array = data;
    //                 for (let i = 0; i < data.length; i++) {
    //                     array[i]["id"] = array[i]['proCode'];
    //                     array[i]["value"] = array[i]['proCode'];
    //                     array[i]["text"] = array[i]['proCode'];
    //                 }
    //                 return {results: array};
    //             },
    //         }
    //     });
    // }

    // /** 项目编号下拉框选中 */
    // function selectInfo(obj) {
    //     $(".proCode").on("select2:select", function () {
    //         let i = $(obj).attr("data-index");
    //         debugger
    //         $("#proName_" + i).val($(obj).select2("data")[0].proName);
    //         $("#proQty_" + i).val($(obj).select2("data")[0].proQty);
    //         $("#proUnit_" + i).val($(obj).select2("data")[0].proUnit);
    //     })
    // }

    /** 替换特殊字符 */
    function toTextarea(str) {
        var reg = new RegExp("<br>", "g");
        var regSpace = new RegExp("&ensp;", "g");
        str = str.replace(reg, "\n");
        str = str.replace(regSpace, " ");
        return str;
    }

    /** 点击明细表中的总金额，重新计算报价单总金额 */
    function keyup() {
        let totalPriceIncludeTax = 0;
        for(var j = 1; j <= index; j++){
            if($("#" +  "totalPriceIncludeTax_" + j ).val() != null){
                totalPriceIncludeTax = Math.round((Number(totalPriceIncludeTax) + Number($("#totalPriceIncludeTax_" + j).val())) * 100) / 100;
            }
        }
        $("#queryForm input[name ='totalAmountIncludedTax']").val(totalPriceIncludeTax);
        var totalPriceIncludeTaxInWords = String(totalPriceIncludeTax);
        // for (i = totalPriceIncludeTax.length - 1; i >= 0; i--) {
        //     totalPriceIncludeTax = totalPriceIncludeTax.replace(",", "")//替换tomoney()中的“,”
        //     totalPriceIncludeTax = totalPriceIncludeTax.replace(" ", "")//替换tomoney()中的空格
        // }
        // totalPriceIncludeTax = totalPriceIncludeTax.replace("￥", "")//替换掉可能出现的￥字符
        // if (isNaN(totalPriceIncludeTax)) { //验证输入的字符是否为数字
        //     alert("请检查小写金额是否正确");
        //     return;
        // }
        // ---字符处理完毕，开始转换，转换采用前后两部分分别转换---

        var part = String(totalPriceIncludeTaxInWords).split(".");
        var newchar = '';
        //小数点前进行转化
        for (i = part[0].length - 1; i >= 0; i--) {
            if (part[0].length > 10) {
                alert("位数过大，无法计算");
                return "";
            } //若数量超过拾亿单位，提示
            tmpnewchar = ""
            perchar = part[0].charAt(i);
            switch (perchar) {
                case "0":
                    tmpnewchar = "零" + tmpnewchar;
                    break;
                case "1":
                    tmpnewchar = "壹" + tmpnewchar;
                    break;
                case "2":
                    tmpnewchar = "贰" + tmpnewchar;
                    break;
                case "3":
                    tmpnewchar = "叁" + tmpnewchar;
                    break;
                case "4":
                    tmpnewchar = "肆" + tmpnewchar;
                    break;
                case "5":
                    tmpnewchar = "伍" + tmpnewchar;
                    break;
                case "6":
                    tmpnewchar = "陆" + tmpnewchar;
                    break;
                case "7":
                    tmpnewchar = "柒" + tmpnewchar;
                    break;
                case "8":
                    tmpnewchar = "捌" + tmpnewchar;
                    break;
                case "9":
                    tmpnewchar = "玖" + tmpnewchar;
                    break;
            }
            switch (part[0].length - i - 1) {
                case 0:
                    tmpnewchar = tmpnewchar + "元";
                    break;
                case 1:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "拾";
                    break;
                case 2:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "佰";
                    break;
                case 3:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "仟";
                    break;
                case 4:
                    tmpnewchar = tmpnewchar + "万";
                    break;
                case 5:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "拾";
                    break;
                case 6:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "佰";
                    break;
                case 7:
                    if (perchar != 0) tmpnewchar = tmpnewchar + "仟";
                    break;
                case 8:
                    tmpnewchar = tmpnewchar + "亿";
                    break;
                case 9:
                    tmpnewchar = tmpnewchar + "拾";
                    break;
            }
            newchar = tmpnewchar + newchar;
        }
        if (totalPriceIncludeTaxInWords.indexOf(".") != -1) {
            //小数点之后进行转化
            if (part[1].length > 2) {
                alert("小数点之后只能保留两位,系统将自动截段");
                part[1] = part[1].substr(0, 2)
            }
            for (i = 0; i < part[1].length; i++) {
                tmpnewchar = ""
                perchar = part[1].charAt(i)
                switch (perchar) {
                    case "0": tmpnewchar = "零" + tmpnewchar; break;
                    case "1": tmpnewchar = "壹" + tmpnewchar; break;
                    case "2": tmpnewchar = "贰" + tmpnewchar; break;
                    case "3": tmpnewchar = "叁" + tmpnewchar; break;
                    case "4": tmpnewchar = "肆" + tmpnewchar; break;
                    case "5": tmpnewchar = "伍" + tmpnewchar; break;
                    case "6": tmpnewchar = "陆" + tmpnewchar; break;
                    case "7": tmpnewchar = "柒" + tmpnewchar; break;
                    case "8": tmpnewchar = "捌" + tmpnewchar; break;
                    case "9": tmpnewchar = "玖" + tmpnewchar; break;
                }
                if (i == 0) tmpnewchar = tmpnewchar + "角";
                if (i == 1) tmpnewchar = tmpnewchar + "分";
                newchar = newchar + tmpnewchar;
            }
        }
        //替换所有无用汉字，直到没有此类无用的数字为止
        while (newchar.search("零零") != -1 || newchar.search("零亿") != -1 || newchar.search("亿万") != -1 || newchar.search("零万") != -1) {
            newchar = newchar.replace("零亿", "亿");
            newchar = newchar.replace("亿万", "亿");
            newchar = newchar.replace("零万", "万");
            newchar = newchar.replace("零零", "零");
        }
        while (newchar.search("零元") != -1) {
            newchar = newchar.replace("零元", "元");
        }
        while (newchar.search("零角") != -1) {
            newchar = newchar.replace("零角", "");
        }
        while (newchar.search("零分") != -1) {
            newchar = newchar.replace("零分", "");
        }
        //替换以"一十"开头的，为"十"
        if (newchar.indexOf("壹拾") == 0) {
            newchar = newchar.substr(1);
        }
        //替换以"零"结尾的，为""
        if (newchar.lastIndexOf("零") == newchar.length - 1) {
            newchar = newchar.substr(0, newchar.length - 1);
        }
        if (newchar.charAt(newchar.length - 1) == "元" || newchar.charAt(newchar.length - 1) == "角")
            newchar = newchar + "整"
        //  document.write(newchar);
        var taxRate = $("#out").find("tr").eq(0).find("input[name=taxRate]").val();
        $("#queryForm input[name ='totalAmtIncTaxInWords']").val('人民币' + newchar + '（含'+ taxRate+'%增值税）');
    }

    /** 在固定的td里面填充select*/
    function addItem(index){
        var reasonArry =  JSON.parse(sessionStorage.getItem("payItems"));

        $("#payItem_"+index1).append(`<option value="">请选择</option>`);
        reasonArry.forEach(value => {
            if (value) {
                $("#payItem_"+index1).append(`<option value="${value.id}">${value.name}</option>`);
            }
        })
    }

    /** 动态获取变更原因*/
    function dynamicItem(){
        js.post({
            url: ctx + "quoteManage/createQuotation/payItem",
            data: {},
            success: function (result) {
                if (result.length>0) {
                    sessionStorage.setItem("payItems",JSON.stringify(result));
                } else {
                    js.modal.warning(result.msg);
                }
            }
        })
    }

    /**
     * 检测行索引是否存在
     * @param index
     */
    function checkIndex(index) {
        if (indexArray.indexOf(index) > -1) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 打开添加报价任务列表模态框
     */
    $('#queryForm').on('click', '.out-search',function () {
        $("bootstrap-table2").bootstrapTable('destroy');
        table2 = js.table.init({
            queryForm: 'queryForm-task',
            url: ctx + "quoteManage/createQuotation/qttTaskList",
            id: 'bootstrap-table2',
            showColumns: false,
            showExport: false,
            pagination: false,
            onLoadSuccess: function (data) {
                var dataSource = $('#bootstrap-table2').bootstrapTable('getData', true);
            },
            columns: [
                {
                    title:'<input class="checkboxAll"  type="checkbox" onclick="selectedAll()" >',width: '40',
                    formatter: function (value, row, index) {
                        return '<input class="checkbox_select"  type="checkbox" name= "checkbox_select" value="'+ $('<div/>').text(row.proName).html() +'"  taskIds = "'+ $('<div/>').text(row.quoteTaskId).html() +'" customers = "'+ $('<div/>').text(row.consumerName).html() +'">';
                    }
                },
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '项目名称', field: 'proName', width: '250'},
                {title: '项目编号', field: 'proCode', width: '150'},
                {title: '需方名称', field: 'consumerName', width: '250'},
                {title: '数量', field: 'proQty', width: '100'},
                {title: '单位', field: 'proUnit', width: '100'},
                // {
                //     title: '概算状态', field: 'budgetProcessStatus', width: '150',
                //     formatter: function (value, row, index) {
                //         if (value === 1) {
                //             return '<span class="badge ' + ["label-default"] + '">' + '未开始' + '</span> ';
                //         } else if (value === 2) {
                //             return '<span class="badge ' + ["label-info"] + '">' + '执行中' + '</span> ';
                //         } else if (value === 3) {
                //             return '<span class="badge ' + ["label-success"] + '">' + '已完成' + '</span> ';
                //         }
                //     }
                // },
                {
                    title: '报价状态', field: 'quoteProcessStatus', width: '150',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<span class="badge ' + ["label-default"] + '">' + '未开始' + '</span> ';
                        } else if (value === 2) {
                            return '<span class="badge ' + ["label-info"] + '">' + '执行中' + '</span> ';
                        } else if (value === 3) {
                            return '<span class="badge ' + ["label-success"] + '">' + '已完成' + '</span> ';
                        }
                    }
                },
                {title: '任务下达日期', field: 'assignTime', width: '150'}
            ]
        });
        index2 = $(this).parents("tr").find("td:first").text();
        js.modal.open('modal-qttTaskList');
        js.modal.closeLoading();
    });

    /**
     *全选
     */
    function selectedAll() {
        if ($('.checkboxAll').is(":checked")) {
            $('.checkbox_select').each(function () {
                this.checked = true;
            });
        } else {
            $('.checkbox_select').each(function () {
                this.checked = false;
            });
        }
    }

    /**
     * 是否选运输之后，运输方式变更
     * @param transValue
     */
    function checkTransBox(transValue) {
        if (transValue == true){
            $("#queryForm input[name='transMethod']").val("（始发地—目的地）");
        }else{
            $("#queryForm input[name='transMethod']").val("（买方于卖方厂内自提）");
        }
    }

    //根据付款比例计算付款金额
    function computePayAmount(obj){
        debugger
        var payPercentId = obj.getAttribute("id");
        var id = payPercentId.substring(11);
        var payAmount = $("#payPercent_" + id).val() * 0.01 * $("#queryForm input[name='totalAmountIncludedTax']").val();
        var payAmountRount = Math.round(payAmount * 100) / 100;
        $("#payAmount_" + id).val(payAmountRount);
    }

    var table1;
    var table;
    var table2;
    $(function () {
        //初始化第一行ID索引
        index = $("#quotationQty").val();
        indexArray.push(index);
        index1 = $("#qttItemQty").val();
        // /** 项目编号下拉框 */
        // select3();
        /** 动态获取款项*/
        dynamicItem();
        /** 将textarea内的信息显示为字符串 */
        var str = $("#queryForm textarea[name ='quoteBottomDesc']").val();
        $("#queryForm textarea[name ='quoteBottomDesc']").val(toTextarea(str));

        //将多个项目名换行
        var objectModel = [[${quotation}]];
        for(i = 1; i <= objectModel.length; i++){
            if(objectModel[i-1].proNames != null){
                var proNames = objectModel[i-1].proNames;
                var t = proNames.split(',').join('<br>');
                $("#names_"+i).html(t);
            }
        }


        /**
         * 加载文件列表
         */
        table1 = js.table.init({
            url: ctx + "quoteManage/createQuotation/fileList",
            showColumns: false,
            showExport: false,
            pagination: false,
            id: 'bootstrap-table1',
            onLoadSuccess: function (data) {
                var dataSource = $('#bootstrap-table1').bootstrapTable('getData', true);
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '文件名称', field: 'fileName', width: '250'},
                {
                    title: '文件类型', field: 'fileType', width: '150',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (value == 1) {
                            return '纸版报价单';
                        } else if (value == 2) {
                            return '其他相关文件';
                        } else return '';
                        return actions.join('');
                    }
                },
                {title: '上传日期', field: 'fileUploadDate', width: '150'},
                {title: '上传者', field: 'userName', width: '150'},
                {title: '文件备注', field: 'fileComment', width: '150'},
                {
                    title: '操作', field: 'fileUrl', width: '180',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (value) {
                            if (hasP("quo:await:fileInfoEdit")) {
                                actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openUploadFile(' + row.fileId + ')"> 编辑</a> ');
                            }
                            if (hasP("quo:await:upload")){
                                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delFile(' + row.fileId + ')"> 删除</a> ');
                            }
                            if (hasP("quo:await:download")) {
                                actions.push('<a class="btn btn-info btn-xs" href="' + row.fileUrl + '" target="_blank"> 下载</a>');
                            }
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        table = js.table.init({
            id: 'bootstrap-table',
            url: ctx + "quoteManage/quoteApprove/appCommentList",
            showColumns: false,
            showExport: false,
            pagination: false,
            queryData: {quoteId: $("#quoteId").val()},
            onLoadSuccess: function (data) {
                var dataSource = $('#bootstrap-table').bootstrapTable('getData', true);
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '审核人', field: 'appName', width: '170'},
                {title: '审核日期', field: 'appDate', width: '170'},
                {title: '审核状态', field: 'appStatus', width: '170',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<span class="badge ' + ["label-danger"] + '">' + '审核驳回' + '</span> ';
                        } else if (value === 2) {
                            return '<span class="badge ' + ["label-success"] + '">' + '审核通过' + '</span> ';
                        }
                    }
                },
                {title: '审核意见', field: 'appRemark'},
            ]
        });

        /** 删除行 */
        $('#queryForm').on('click', '.out-del', function () {
            $(this).parents("tr").remove();
            if ($(".quotationTable tbody tr").length == 0) {
                while (1) {
                    index++;
                    //如果不存在跳出死循环
                    if (checkIndex(index) === false) {
                        break;
                    }
                }
                var namesId = 'names_' + index;
                var taskIds = 'taskIds_' + index;
                var customers = 'customers_' + index;
                // var proUnitId = 'proUnit_' + index;
                var totalPriceIncludeTax = 'totalPriceIncludeTax_' + index;
                $("#out").append(`
                     <tr>
                            <td></td>
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="proName"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center" type="hidden" class="form-control" name="proNames" autocomplete="off" >
                                <div name="names" id="`+ namesId +`">
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="proType" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="proQty"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="text" class="form-control" name="proUnit"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="unitPrice" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="totalPrice" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="number" class="form-control" name="taxRate" autocomplete="off" onKeyUp="keyup()">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="taxAmount" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="unitPriceTaxIncluded" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="number" class="form-control" onKeyUp="keyup()" id = "` + totalPriceIncludeTax + `" name="totalPriceIncludeTax" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="remark" autocomplete="off">
                                <input type="hidden" name = "taskIds" id= "`+taskIds+`">
                                <input type="hidden" name="customers" id = "`+customers+`">
                            </td>
                            <td style="text-align: left;padding-left: 0.5%;">
                                <span class="out-search" title="查找"><i class = "fa fa-search text-light-blue"></i></span>
                                <span class="out-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                                <span class="out-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                            </td>
                     </tr>
                `)
            }
            computerNo();//重新计算序号
            keyup();//加载计算大写金额方法
        });

        /** 删除行 */
        $('#queryForm').on('click', '.item-del', function () {
            $(this).parents("tr").remove();
            if ($(".bottom tbody tr").length == 0) {
                while (1) {
                    index1++;
                    //如果不存在跳出死循环
                    if (checkIndex(index1) === false) {
                        break;
                    }
                }
                var payItemId = 'payItem_' +index1;
                var payPercentId = 'payPercent_'+ index1;
                var payAmountId = 'payAmount_' + index1;
                $("#bottom-body").append(`
                    <tr>
                        <td></td>
                        <td>
                            <select  style="text-align:center;text-align-last: center;" type="text" class="form-control" id="`+ payItemId +`" name="payItem" autocomplete="off">
                            </select>
                        </td>
                        <td colspan="2">
                            <input  style="text-align: center" type="text" class="form-control" name="payCondition" autocomplete="off">
                        </td>
                        <td>
                            <input  style="text-align: center" type="number" class="form-control" name="payPercent"  id="`+ payPercentId +`"
                             onkeyup="computePayAmount(this)"autocomplete="off">
                        </td>
                        <td colspan="2">
                            <input  style="text-align: center" type="number" class="form-control" name="payAmount"  id="`+ payAmountId +`"  autocomplete="off">
                        </td>
                        <td colspan="2"  style="text-align: center">
                            <select  style="text-align:center;text-align-last: center;" type="value" class="form-control" name="payMethod" autocomplete="off">
                            <option value='' selected="selected" style="text-align: center">请选择</option>
                                <option value=1 style="text-align: center">现金</option>
                                <option value=2 style="text-align: center">承兑</option>
                                <option value=3 style="text-align: center">电汇</option>
                                <option value=4 style="text-align: center">支票</option>
                                <option value=5 style="text-align: center">电汇或承兑</option>
                            </select>
                        </td>
                        <td style="text-align: left;padding-left: 0.5%; border: 0px">
                            <span class="item-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                            <span class="item-del" title="删除" ><i class="fa fa-remove text-red"></i> </span>
                        </td>
                    </tr>
                    `);
            }
            addItem();//款项节点下拉框
            computerNo1(); //重新计算序号
        });

        /**
         * 保存创建和修改的报价单
         */
        $("#btn-save-mainQuote").click(function () {
            var customersArray = "";
            for(var w = 0; w <= index; w++){
                if($("#customers_" + w).val() != undefined){
                    customersArray = customersArray + $("#customers_" + w).val();
                }
            }
            customersArray = customersArray.slice(0,customersArray.length-1);
            var customersArray1 = customersArray.split('/');
            var count = 0;
            for (var k = 0; k < customersArray1.length; k++) {
                if (customersArray1[k] != $("#queryForm select[name ='consumerName'] option:selected").text()) {
                    count++;
                }
            }
            if(count > 0){
                js.modal.confirm("所选项目需方与客户名称不一致,是否仍然保存！");
            }
            //验证'proName', 'payItem', 'payMethod','proNames'列不为空
            let $this = $(this);
            let res = js.vd({
                id: 'queryForm',
                notEmpty: ['proName', 'payItem', 'payMethod','proNames']
            });
            if (!res) {
                return;
            }

            //验证选择了重复的任务
            var taskIdArray = "";
            for(var i = 0; i <= index+1; i++){
                if($("#taskIds_" + i).val() != undefined){
                    taskIdArray = taskIdArray + $("#taskIds_" + i).val();
                }
            }
            taskIdArray = taskIdArray.slice(0,taskIdArray.length-1);
            var taskIdArray1 = taskIdArray.split(',');
            var nary = taskIdArray1.sort();
            for(var j = 0;j < nary.length;j++){
                if (nary[j] == nary[j+1]){
                    js.modal.alert('选择了重复的报价项目！');
                    return;
                }
            }

            //验证款项百分比总和是否是100
            let payPercent = 0;
            for(var h = 0; h <= index1; h++){
                if($("#payPercent_" + h).val() != null){
                    payPercent = Number(payPercent) + Number($("#payPercent_" + h).val());
                }
            }
            if(payPercent != 100){
                js.modal.alert("付款比例总和不等于100%！");
                return;
            }

            //验证款项总金额等不等于报价总金额
            function accAdd(arg1,arg2){undefined
                var r1,r2,m;
                try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
                try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
                m=Math.pow(10,Math.max(r1,r2));
                return (arg1*m+arg2*m)/m;
            }
            let payAmount = 0;
            for(var j = 0; j <= index1; j++){
                if($("#payAmount_" + j).val() != null){
                    payAmount =accAdd(payAmount,$("#payAmount_" + j).val());
                    // payAmount = Number(payAmount) + Number($("#payAmount_" + j).val());
                }
            }
            if(payAmount != $("#queryForm input[name ='totalAmountIncludedTax']").val()){
                js.modal.alert("合同总金额之和不等于报价总金额！");
                return;
            }
            $this.attr('disabled', true);

            js.submit({
                formId: "queryForm",
                url: ctx + "quoteManage/createQuotation/editSave",
                data: new FormData($("#queryForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        window.parent.getItemCount();
                        setTimeout(function () {
                            location.href = ctx + "quoteManage/quotationManage/page" ;
                        }, 500);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        });

        /**
         * 保存上传文件及信息
         */
        $("#btn-save-file").click(function () {
            var $this = $(this);
            if (!$this.parents(".modal").find("input[name='file']").get(0).files[0] && $("#file").is(":visible")) {
                js.modal.warning("请至少选择一个文件");
                return false;
            }
            js.submit({
                url: ctx + "quoteManage/file/upload",
                data: new FormData($this.parents(".modal").find("form")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.reset("fileForm-send");
                        js.modal.hide("modal-uploadFile");
                        js.table.refresh(table1);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        });

        /**
         * 添加报价明细
         */
        $('#queryForm').on('click', '.out-add', function () {
            while (1) {
                index++;
                //如果不存在跳出死循环
                if (checkIndex(index) === false) {
                    break;
                }
            }
            var namesId = 'names_' + index;
            var taskIds = 'taskIds_' + index;
            var customers = 'customers_' + index;
            // var proUnitId = 'proUnit_' + index;
            var totalPriceIncludeTax = 'totalPriceIncludeTax_' + index;
            $(this).parents("tr").after(`
                     <tr>
                            <td></td>
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="proName"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center" type="hidden" class="form-control" name="proNames" autocomplete="off">
                                <div name="names"  id="`+ namesId +`">
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="proType" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="proQty"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="text" class="form-control" name="proUnit"  autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="unitPrice" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="totalPrice" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="number" class="form-control" name="taxRate" autocomplete="off" onKeyUp="keyup()">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="taxAmount" autocomplete="off">
                            </td>
                            <td>
                                <input style="text-align: center"  type="number" class="form-control" name="unitPriceTaxIncluded" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="number" class="form-control" onKeyUp="keyup()" id = "` + totalPriceIncludeTax + `" name="totalPriceIncludeTax" autocomplete="off">
                            </td>
                            <td>
                                <input  style="text-align: center" type="text" class="form-control" name="remark" autocomplete="off">
                                <input type="hidden" name = "taskIds" id= "`+taskIds+`">
                                <input type="hidden" name = "customers" id = "`+customers+`">
                            </td>
                            <td style="text-align: left;padding-left: 0.5%;">
                                <span class="out-search" title="查找"><i class = "fa fa-search text-light-blue"></i></span>
                                <span class="out-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                                <span class="out-del" title="删除"><i class="fa fa-remove text-red"></i> </span>
                            </td>
                     </tr>
                `)
            computerNo();//重新计算序号
            keyup();//加载计算大写金额方法
        });

        /**
         * 添加款项明细
         */
        $('#queryForm').on('click', '.item-add', function () {
            while (1) {
                index1++;
                //如果不存在跳出死循环
                if (checkIndex(index1) === false) {
                    break;
                }
            }
            var payItemId = 'payItem_' +index1;
            var payPercentId = 'payPercent_'+ index1;
            var payAmountId = 'payAmount_' + index1;
            $(this).parents("tr").after(`
                                <tr>
                                    <td></td>
                                    <td>
                                        <select  style="text-align:center;text-align-last: center;" type="text" class="form-control" id="`+ payItemId +`" name="payItem" autocomplete="off">
                                        </select>
                                    </td>
                                    <td colspan="2">
                                        <input  style="text-align: center" type="text" class="form-control" name="payCondition" autocomplete="off">
                                    </td>
                                    <td>
                                        <input  style="text-align: center" type="number" class="form-control" name="payPercent"  id="`+ payPercentId +`" onkeyup="computePayAmount(this)" autocomplete="off">
                                    </td>
                                    <td colspan="2">
                                        <input  style="text-align: center" type="number" class="form-control" name="payAmount"  id="`+ payAmountId +`"  autocomplete="off">
                                    </td>
                                    <td colspan="2"  style="text-align: center">
                                        <select  style="text-align:center;text-align-last: center;" type="value" class="form-control" name="payMethod" autocomplete="off">
                                        <option value='' selected="selected" style="text-align: center">请选择</option>
                                            <option value=1 style="text-align: center">现金</option>
                                            <option value=2 style="text-align: center">承兑</option>
                                            <option value=3 style="text-align: center">电汇</option>
                                            <option value=4 style="text-align: center">支票</option>
                                            <option value=5 style="text-align: center">电汇或承兑</option>
                                        </select>
                                    </td>
                                    <td style="text-align: left;padding-left: 0.5%; border: 0px">
                                        <span class="item-add" title="添加"><i class="fa fa-plus text-green"></i> </span>
                                        <span class="item-del" title="删除" ><i class="fa fa-remove text-red"></i> </span>
                                    </td>
                                </tr>
                                `);
            addItem();//款项节点下拉框
            computerNo1(); //重新计算序号
        });

        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-qttTaskList", function () {
            js.reset("queryForm-task");
        });

        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-uploadFile", function () {
            js.reset("fileForm-send");
        });

        /** 将选中的任务信息带回至报价明细列表*/
        $("#btn-submit-qttTask").click(function () {
            var quoteTaskIds = new Array();
            var proNames = new Array();
            var customerNames = new Array();
            $('input[name="checkbox_select"]:checkbox:checked').each(function(i,value,taskIds,customers){
                proNames += $(this).attr("value")+",";
            });
            $('input[name="checkbox_select"]:checkbox:checked').each(function(i,value,taskIds,customers){
                quoteTaskIds += $(this).attr("taskIds")+"/";
            });
            $('input[name="checkbox_select"]:checkbox:checked').each(function(i,value,taskIds,customers){
                customerNames += $(this).attr("customers")+"/";
            });
            $('#out').find("tr").eq(index2 - 1).find("input[name=taskIds]").val(quoteTaskIds);
            $('#out').find("tr").eq(index2 - 1).find("input[name=proNames]").val(proNames);
            $('#out').find("tr").eq(index2 - 1).find("input[name=customers]").val(customerNames);
            $('#out').find("tr").eq(index2 - 1).find("div[name=names]").text(proNames.split(',').join('<br>'));
            $('#out').find("tr").eq(index2 - 1).find("div[name=names]").html($('#out').find("tr").eq(index2 - 1).find("div[name=names]").text());
            js.modal.hide('modal-qttTaskList');
        });
    });
</script>
</body>
</html>

